package com.wn55.hrms.mapper;

import com.wn55.hrms.entity.RecruitRequire;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;


import java.util.List;

@Repository
public interface RecruitRequireMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(RecruitRequire record);

    RecruitRequire selectByPrimaryKey(Integer id);

    List<RecruitRequire> selectAll();

    int updateByPrimaryKey(RecruitRequire record);


    /**
     * 查询所有需求
     * @param deptName
     * @param requireType
     * @param postName
     * @return
     */
    List<RecruitRequire> selectRequireByConds(@Param("deptName") String deptName, @Param("requireType") String requireType, @Param("postName") String postName);

    @Insert(value= "insert into recruit_require (require_name, require_type, dept_name, post_id, post_code,post_name, numbers,is_delete) " +
            "values(#{requireName},#{requireType},#{deptName},#{postId},#{postCode},#{postName},#{numbers},0)")
    @Options(useGeneratedKeys = true,keyProperty ="id",keyColumn = "id")
    void insertRequire(RecruitRequire recruitRequire);


    @Update("update recruit_require set require_name=#{requireName},require_type=#{requireType},dept_name=#{deptName},post_id=#{postId}," +
            "post_code=#{postCode},post_name=#{postName},numbers=#{numbers},is_delete=0 where id = #{id}")
    void updateRequire(RecruitRequire recruitRequire);
}